#include "my_combo_send.h"
#include <QListView>

My_combo_send::My_combo_send(const QString &title, QWidget *parent) : QGroupBox(title, parent)
{
    this->setAlignment(Qt::AlignCenter);
    combo = new QComboBox(this);

    // 设置样式表时会起作用
    QListView* listView = new QListView();
    combo->setView(listView);

    btn = new QPushButton("发送", this);
    layout = new QHBoxLayout();
    layout->addWidget(combo);
    layout->addWidget(btn);
    layout->setContentsMargins(LEFT_M, TOP_M, RIGHT_M, BOTTOM_M);
    layout->setSpacing(SPACE_SON);
    this->setLayout(layout);
}

void My_combo_send::setEnabled(bool flag)
{
    btn->setEnabled(flag);
}

void My_combo_send::addItems(const QStringList &texts)
{
    combo->addItems(texts);
}

void My_combo_send::setCurrentIndex(int index)
{
    combo->setCurrentIndex(index);
}

QString My_combo_send::currentText()
{
    return combo->currentText();
}
